(use-modules
 ;; SRFI 64 for unit testing facilities
 (srfi srfi-64)
 ;; Utilities for testing
 (utils random-utils))


(test-begin "random-utils-test")


(test-group
 "make-random-integer-generator"
 (test-assert "make-random-integer-generator seeded gives always same integers"
   (let ([seed 1248]
         [num-of-rand-ints 100]
         [upper-bound 1000])
     (equal?
      (let ([rand-int (make-random-integer-generator #:seed seed)])
        (let loop ([remaining-rand-ints num-of-rand-ints]
                   [generated-rand-ints '()])
          (cond
           [(= remaining-rand-ints 0) generated-rand-ints]
           [else
            (loop (- remaining-rand-ints 1)
                  (cons (rand-int upper-bound)
                        generated-rand-ints))])))
      (let ([rand-int (make-random-integer-generator #:seed seed)])
        (let loop ([remaining-rand-ints num-of-rand-ints]
                   [generated-rand-ints '()])
          (cond
           [(= remaining-rand-ints 0) generated-rand-ints]
           [else
            (loop (- remaining-rand-ints 1)
                  (cons (rand-int upper-bound)
                        generated-rand-ints))])))))))


(test-end "random-utils-test")
